import {Switch,Route,Redirect} from 'react-router-dom';

function RouterView({routes}){
    let routeArr = routes.filter(item => item.component);
    let redirectArr = routes.filter(item => item.redirect);
    return <Switch>
        {routeArr.map(item => <Route path={item.path} component={(props) => {
            return <item.component routes={item.children} {...props}></item.component>
        }} key={item.path}></Route>)}
        {redirectArr.map(item => <Redirect from={item.path} to={item.redirect} key={item.path}></Redirect>)}
    </Switch>
}

export default RouterView